package com.zszedu.web.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

@Component
public class RedisConfig {
    @Autowired
    private  RedisTemplate redisTemplate;

    public  ValueOperations getRedis(){
        //初始化存储Key时候的信息，使其保存数据数据时，Key可以是正常名称(可以省略)
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        //获取Redis的Spring
        ValueOperations forValue = redisTemplate.opsForValue();

        return forValue;
    }
}
